package VUTHANHPHUC_HOMEWORK_ARRAY;

public class Models04 {
	private int count;
	private int max;
	private int min;

	public int MinMax(int[] A, boolean a) {
		int max = A[1];
		int min = A[1];
		if (a) {
			for (int i = 2; i < A.length; i++) {
				if (A[i] >= max) {
					max = A[i];
				}
			}
			return max;
		} else {
			for (int i = 2; i < A.length; i++) {
				if (A[i] <= min) {
					min = A[i];
				}
			}
			return min;
		}
	}

	public String Index(int[] A, boolean a) {
		int[] B = new int[A.length];
		String s = "";
		int j = 0;
		if (a) {
			for (int i = 0; i < A.length; i++) {
				if (A[i] == MinMax(A, true)) {
					B[j] = i + 1;
					j++;
				}
			}
			for (int i = 0; i < j; i++) {
				s += i < j - 1 ? B[i] + ", " : B[i];
			}

		} else {
			for (int i = 0; i < A.length; i++) {
				if (A[i] == MinMax(A, false)) {
					B[j] = i + 1;
					j++;
				}
			}
			for (int i = 0; i < j; i++) {
				s += i < j - 1 ? B[i] + ", " : B[i];
			}
		}
		return s;

	}

}
